<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<style type="text/css">
		.box{
			width: 600px;
			height: 400px;
			border: 1px solid red;
			position: relative;
			margin: 0 auto;
			overflow: hidden;
		}
		.ball{
			position: absolute;
			border-radius: 50%;
			background-color: red;
		}
	</style>
</head>
<body>
	<div class="box"></div>
</body>
<script type="text/javascript">
	var box=document.getElementsByClassName("box")[0];
	var ball=document.createElement("div");
	function(){
		ball.style.width="+reand+px";
		var timer=setInterval(function(){
			if (ball) {}
		},10)
		box.appendChild(ball);
	}
	function reand(min,max){
		return parseInt(Math.random()*(max-min)+min);
	}
</script>
</html>